package org.aeon.heroicsagatextedition.game;

import org.aeon.heroicsagatextedition.exception.GameException;
import org.aeon.heroicsagatextedition.game.Backup.GameBackup;

/**
 * @projectName: HeroicSagaTextEdition
 * @package: org.aeon.heroicsagatextedition.game
 * @className: GameSettlement
 * @author: MissingAeon
 * @date: 2023/12/25 10:25
 * @description: 游戏结算
 */
public class GameSettlement {
    private static GameSettlement gameSettlement;
    private boolean state = true;
    private boolean isVictory = false;

    /**
     * 正常的的胜利失败
     *
     * @param isVictory
     */
    public GameSettlement(boolean isVictory) {
        this.state = false;
        this.isVictory = isVictory;
        gameSettlement = this;
        GameBackup.cleanUp();
        System.out.println("游戏结束，" + (isVictory ? "恭喜您游戏获胜！" : "很可惜，游戏失败，再接再厉！"));
    }

    /**
     * 中途退出
     */
    public GameSettlement() {
        this.state = false;
        gameSettlement = this;
        System.out.println("游戏保存，点击继续游戏可继续游玩！");
    }

    /**
     * 获取当前游戏状态
     *
     * @return
     */
    public static boolean isState() {
        if (gameSettlement != null) {
            return gameSettlement.state;

        }
        return true;
    }

    /**
     * 设置游戏状态
     *
     * @param state
     */
    public static void setState(boolean state) {
        if (gameSettlement != null) {
            gameSettlement.state = state;
        }
    }

}
